﻿using RecruitStudents.Client.Appointment;
using RecruitStudents.Client.Base;
using RecruitStudents.Client.Consult;
using RecruitStudents.Client.Examinee;
using RecruitStudents.Client.Financial;
using RecruitStudents.Client.Loading;
using RecruitStudents.Client.Lottery;
using RecruitStudents.Client.OnSiteSign;
using RecruitStudents.Client.Score;
using RecruitStudents.Client.Secretary;
using RecruitStudents.Utility;
using RecruitStudents.Utility.Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client
{
    public partial class Main : BaseForm
    {
        public Main()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
            this.lbDate.Text = "时间:" + DateTime.Now.DateTimeToyyyy_MM_dd();
            if (SessionerHelper.UserType != "0")
            {
                string strUserRight = SessionerHelper.UserRight;
                if (!string.IsNullOrEmpty(strUserRight))
                {
                    List<string> listUserRight = strUserRight.Split(',').ToList();
                    xtraTabPage100.PageEnabled = listUserRight.Contains("100");
                    xtraTabPage200.PageEnabled = listUserRight.Contains("200");
                    xtraTabPage300.PageEnabled = listUserRight.Contains("300");
                    xtraTabPage400.PageEnabled = listUserRight.Contains("400");
                    xtraTabPage500.PageEnabled = listUserRight.Contains("500");
                }
            }
            SetLabelText();
        }
        private void SetLabelText()
        {
            lbLoginName.Text = "登录人: " + SessionerHelper.UserName;
            lbExamPlace.Text = "考点: " + SessionerHelper.ExamPlaceName;
            lbSpecialityKindsName.Text = "专业: " + SessionerHelper.SpecialityKinds;
            lbExamLevel.Text = "级别: " + SessionerHelper.ExamLevelName;
            //if (SessionerHelper.SpecialityKindsNO.ToSafeString().Length > 0)
            //{
            //    if (SessionerHelper.SpecialityKindsNO.ToSafeString().Split(',').Length > 1)
            //    {
            //        OnSiteSign_OnSiteSignForm.Enabled = false;
            //        Appointment_MakeAppointmentForm_First.Enabled = false;
            //        Lottery_MakeLotteryForm_First.Enabled = false;
            //        Secretary_SecretaryManagerForm.Enabled = false;
            //    }
            //    else
            //    {
            //        OnSiteSign_OnSiteSignForm.Enabled = true;
            //        Appointment_MakeAppointmentForm_First.Enabled = true;
            //        Lottery_MakeLotteryForm_First.Enabled = true;
            //        Secretary_SecretaryManagerForm.Enabled = true;
            //    }
            //}
        }


        #region 考试信息设置
        private void Base_Mac_Click(object sender, EventArgs e)
        {
            Base_Mac_List form = new Base_Mac_List();
            form.Show();
        }

        private void Base_Teacher_Click(object sender, EventArgs e)
        {
            Base_Teacher_List form = new Base_Teacher_List();
            form.Show();
        }

        private void Base_ExamPlace_SpecialityKinds_Group_Click(object sender, EventArgs e)
        {
            Base_ExamPlace_SpecialityKinds_Group_List form = new Base_ExamPlace_SpecialityKinds_Group_List();
            form.Show();
        }

        private void Base_ExamRoom_Click(object sender, EventArgs e)
        {
            Base_ExamRoom_List form = new Base_ExamRoom_List();
            form.Show();
        }

        private void Base_Teacher_ExamRoom_Click(object sender, EventArgs e)
        {
            Base_Teacher_ExamRoom_List form = new Base_Teacher_ExamRoom_List();
            form.Show();
        }

        #endregion

        #region Pad评分设置
        private void Base_Pad_LoginSetting_Click(object sender, EventArgs e)
        {
            Base_Pad_LoginSetting_List form = new Base_Pad_LoginSetting_List();
            form.Show();
        }

        private void Base_Pad_ExamScoreFiedSetting_Click(object sender, EventArgs e)
        {
            Base_Pad_ExamScoreFiedSetting_List form = new Base_Pad_ExamScoreFiedSetting_List();
            form.Show();
        }

        private void Base_Pad_ExamScoreHisSetting_Click(object sender, EventArgs e)
        {
            Base_Pad_ExamScoreHisSetting_List form = new Base_Pad_ExamScoreHisSetting_List();
            form.Show();
        }

        private void Base_Pad_ExamScorePageSetting_Click(object sender, EventArgs e)
        {
            Base_Pad_ExamScorePageSetting_List form = new Base_Pad_ExamScorePageSetting_List();
            form.Show();
        }
        #endregion

        #region 系统设置
        private void Base_BaseData_Setting_Click(object sender, EventArgs e)
        {
            Base_BaseData_Setting_List form = new Base_BaseData_Setting_List();
            form.Show();
        }

        private void Base_SpecialityKinds_Click(object sender, EventArgs e)
        {
            Base_SpecialityKinds_List form = new Base_SpecialityKinds_List();
            form.Show();
        }

        private void Base_SpecialityKindsDetailEditForm_Click(object sender, EventArgs e)
        {
            Base_SpecialityKindsDetailEditForm_List form = new Base_SpecialityKindsDetailEditForm_List();
            form.Show();
        }

        private void Base_ExamCalculateTypeForm_Click(object sender, EventArgs e)
        {
            Base_ExamCalculateTypeForm_List form = new Base_ExamCalculateTypeForm_List();
            form.Show();
        }

        private void Base_ExamScoreTypeForm_Click(object sender, EventArgs e)
        {
            Base_ExamScoreTypeForm_List form = new Base_ExamScoreTypeForm_List();
            form.Show();
        }

        private void Base_SpecialitySetForm_Click(object sender, EventArgs e)
        {
            Base_SpecialitySetForm_List form = new Base_SpecialitySetForm_List();
            form.Show();
        }

        private void Base_Dic_Click(object sender, EventArgs e)
        {
            Base_Dic_List form = new Base_Dic_List();
            form.Show();
        }

        private void Base_ExamPlace_Click(object sender, EventArgs e)
        {
            Base_ExamPlace_List form = new Base_ExamPlace_List();
            form.Show();
        }

        private void Base_ExamPlace_SpecialityKinds_Click(object sender, EventArgs e)
        {
            Base_ExamPlace_SpecialityKinds_List form = new Base_ExamPlace_SpecialityKinds_List();
            form.Show();
        }

        private void Base_ExamPlace_SpecialityKinds_Group_1_Click(object sender, EventArgs e)
        {
            Base_ExamPlace_SpecialityKinds_Group_List form = new Base_ExamPlace_SpecialityKinds_Group_List();
            form.Show();
        }

        private void Base_Dic_NMTSignUp_Click(object sender, EventArgs e)
        {
            Base_Dic_NMTSignUp_List form = new Base_Dic_NMTSignUp_List();
            form.Show();
        }
        #endregion

        #region 权限管理
        private void Base_User_Click(object sender, EventArgs e)
        {
            Base_User_List form = new Base_User_List();
            form.Show();
            //FormCollection fc = Application.OpenForms;
            //if (fc["Base_User_List"] != null)
            //{
            //    (fc["Base_User_List"] as Form).Show();
            //}
            //else
            //{
            //    Base_User_List form = new Base_User_List();
            //    form.Show();
            //}
        }

        private void Base_Role_Click(object sender, EventArgs e)
        {
            Base_Role_List form = new Base_Role_List();
            form.Show();
        }
        #endregion

        #region 咨询互动
        private void Consult_ConsultForm_Type_Click(object sender, EventArgs e)
        {
            ConsultForm_Type_List form = new ConsultForm_Type_List();
            form.Show();
        }

        private void Consult_ConsultForm_Click(object sender, EventArgs e)
        {
            ConsultForm_List form = new ConsultForm_List();
            form.Show();
        }

        private void Consult_ConsultForm_Query_Click(object sender, EventArgs e)
        {
            ConsultForm_Query_List form = new ConsultForm_Query_List();
            form.Show();
        }
        #endregion

        #region 财务管理
        private void Financial_OnSitePayFeeForm_Click(object sender, EventArgs e)
        {
            if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty)
            {
                ChooseForm_ExamPlace option = new ChooseForm_ExamPlace();
                if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SetLabelText();
                }
            }
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty)
            {
                Financial_OnSitePayFeeForm_List form = new Financial_OnSitePayFeeForm_List();
                form.Show();
            }
        }

        private void Financial_OnSitePayFeeForm_Query_Click(object sender, EventArgs e)
        {
            Financial_OnSitePayFeeForm_Query_List form = new Financial_OnSitePayFeeForm_Query_List();
            form.Show();
        }
        #endregion

        #region 考生信息管理
        private void Examinee_OnSiteRegistrationForm_Click(object sender, EventArgs e)
        {
            if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty)
            {
                ChooseForm_ExamPlace option = new ChooseForm_ExamPlace();
                if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SetLabelText();
                }
            }
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty)
            {
                Examinee_StudentRegistration_New form = new Examinee_StudentRegistration_New();
                //Examinee_OnSiteRegistrationForm_List form = new Examinee_OnSiteRegistrationForm_List();
                form.Show();
            }
        }

        private void Examinee_ExameeSearchForm_Click(object sender, EventArgs e)
        {
            Examinee_ExameeSearchForm_List form = new Examinee_ExameeSearchForm_List();
            form.Show();
        }

        private void Examinee_SpecialityExameeSearchForm_Click(object sender, EventArgs e)
        {
            Examinee_SpecialityExameeSearchForm_List form = new Examinee_SpecialityExameeSearchForm_List();
            form.Show();
        }

        private void Examinee_ImportStudentsPhotoForm_Click(object sender, EventArgs e)
        {
            Examinee_ImportStudentsPhotoForm_List form = new Examinee_ImportStudentsPhotoForm_List();
            form.Show();
        }

        private void Examinee_ImportStudentsForm_Click(object sender, EventArgs e)
        {
            Examinee_ImportStudentsForm_List form = new Examinee_ImportStudentsForm_List();
            form.Show();
        }

        private void Examinee_ScoreSearchForm_Click(object sender, EventArgs e)
        {
            Examinee_ScoreSearchForm_List form = new Examinee_ScoreSearchForm_List();
            form.Show();
        }
        #endregion

        #region 成绩管理
        private void Score_ScoreUpForm_Click(object sender, EventArgs e)
        {
            if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty || SessionerHelper.ExamLevel.ToSafeString() == string.Empty || SessionerHelper.SpecialityKindsNO.ToSafeString() == string.Empty)
            {
                ChooseForm_SpecialityKinds option = new ChooseForm_SpecialityKinds();
                if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SetLabelText();
                }
            }
            if (SessionerHelper.SpecialityKindsNO.ToSafeString().Split(',').Length > 1)
            {
                return;
            }
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty &&
                SessionerHelper.ExamLevel.ToSafeString() != string.Empty &&
                SessionerHelper.SpecialityKindsNO.ToSafeString() != string.Empty)
            {
                Score_BrushIDCard_Form form = new Score_BrushIDCard_Form();
                //Score_ScoreUpForm_List form = new Score_ScoreUpForm_List();
                form.Show();
            }
        }

        private void Score_ScoreImportForm_Click(object sender, EventArgs e)
        {
            Score_ScoreImportForm_List form = new Score_ScoreImportForm_List();
            form.Show();
        }

        private void Score_ScoreComposeForm_Click(object sender, EventArgs e)
        {
            Score_ScoreComposeForm_List form = new Score_ScoreComposeForm_List();
            form.Show();
        }

        private void Score_ScorePublishForm_Click(object sender, EventArgs e)
        {
            if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty || SessionerHelper.ExamLevel.ToSafeString() == string.Empty || SessionerHelper.SpecialityKindsNO.ToSafeString() == string.Empty)
            {
                ChooseForm_SpecialityKinds option = new ChooseForm_SpecialityKinds();
                if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SetLabelText();
                }
            }
            if (SessionerHelper.SpecialityKindsNO.ToSafeString().Split(',').Length > 1)
            {
                return;
            }
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty &&
                SessionerHelper.ExamLevel.ToSafeString() != string.Empty &&
                SessionerHelper.SpecialityKindsNO.ToSafeString() != string.Empty)
            {
                Score_ScorePublishForm_List form = new Score_ScorePublishForm_List();
                form.Show();
            }
        }
        #endregion

        #region 考试管理
        private void OnSiteSign_OnSiteSignForm_Click(object sender, EventArgs e)
        {
            ChooseForm option = new ChooseForm();
            if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SetLabelText();
            }
            else
            {
                return;
            }
            //if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty || SessionerHelper.ExamLevel.ToSafeString() == string.Empty ||
            //      SessionerHelper.SpecialityKindsNO.ToSafeString() == string.Empty || SessionerHelper.ExamRoomID.ToSafeString() == string.Empty)
            //{
            //    ChooseForm option = new ChooseForm();
            //    if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            //    {
            //        SetLabelText();
            //    }
            //}
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty &&
                SessionerHelper.ExamLevel.ToSafeString() != string.Empty &&
                SessionerHelper.SpecialityKindsNO.ToSafeString() != string.Empty &&
                SessionerHelper.ExamRoomID.ToSafeString() != string.Empty)
            {
                OnSiteSign_OnSiteSignForm_List form = new OnSiteSign_OnSiteSignForm_List();
                form.Show();
            }
        }

        private void Appointment_MakeAppointmentForm_First_Click(object sender, EventArgs e)
        {
            //if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty || SessionerHelper.ExamLevel.ToSafeString() == string.Empty || SessionerHelper.SpecialityKindsNO.ToSafeString() == string.Empty)
            //{
            //    ChooseForm_SpecialityKinds option = new ChooseForm_SpecialityKinds();
            //    if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            //    {
            //        SetLabelText();
            //    }
            //}
            //if (SessionerHelper.SpecialityKindsNO.ToSafeString().Split(',').Length > 1)
            //{
            //    return;
            //}
            //ChooseForm_SpecialityKinds option = new ChooseForm_SpecialityKinds();
            //if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            //{
            //    SetLabelText();
            //}
            //else
            //{
            //    return;
            //}
            ChooseForm_ExamPlace option = new ChooseForm_ExamPlace();
            if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SessionerHelper.ExamLevel = "1";
                SessionerHelper.ExamLevelName = "初试";
                SetLabelText();
            }
            else
            {
                return;
            }
            //if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty &&
            //    SessionerHelper.ExamLevel.ToSafeString() != string.Empty &&
            //    SessionerHelper.SpecialityKindsNO.ToSafeString() != string.Empty)
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty)
            {
                Appointment_MakeAppointmentForm_First_List form = new Appointment_MakeAppointmentForm_First_List();
                form.Show();
            }
        }

        private void Lottery_MakeLotteryForm_First_Click(object sender, EventArgs e)
        {
            //if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty || SessionerHelper.ExamLevel.ToSafeString() == string.Empty || SessionerHelper.SpecialityKindsNO.ToSafeString() == string.Empty)
            //{
            //    ChooseForm_SpecialityKinds option = new ChooseForm_SpecialityKinds("SelectMulite"); 
            //    if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            //    {
            //        SetLabelText();
            //    }
            //} 
            ChooseForm_SpecialityKinds option = new ChooseForm_SpecialityKinds("SelectMulite");
            if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SetLabelText();
            }
            else
            {
                return;
            }
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty &&
                SessionerHelper.ExamLevel.ToSafeString() != string.Empty &&
                SessionerHelper.SpecialityKindsNO.ToSafeString() != string.Empty)
            {
                Lottery_MakeLotteryForm_First_List form = new Lottery_MakeLotteryForm_First_List();

                form.Show();
            }
        }

        private void Secretary_SecretaryManagerForm_Click(object sender, EventArgs e)
        {
            if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty || SessionerHelper.ExamLevel.ToSafeString() == string.Empty ||
                SessionerHelper.SpecialityKindsNO.ToSafeString() == string.Empty || SessionerHelper.ExamRoomID.ToSafeString() == string.Empty)
            {
                ChooseForm option = new ChooseForm();
                if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SetLabelText();
                }
            }
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty &&
                SessionerHelper.ExamLevel.ToSafeString() != string.Empty &&
                SessionerHelper.SpecialityKindsNO.ToSafeString() != string.Empty &&
                SessionerHelper.ExamRoomID.ToSafeString() != string.Empty)
            {
                Secretary_SecretaryManagerForm_List form = new Secretary_SecretaryManagerForm_List();
                form.Show();
            }
        }

        private void Appointment_MakeAppointmentForm_Second_Click(object sender, EventArgs e)
        {
            if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty || SessionerHelper.ExamLevel.ToSafeString() == string.Empty || SessionerHelper.SpecialityKindsNO.ToSafeString() == string.Empty)
            {
                ChooseForm_SpecialityKinds option = new ChooseForm_SpecialityKinds();
                if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SetLabelText();
                }
            }
            if (SessionerHelper.SpecialityKindsNO.ToSafeString().Split(',').Length == 1)
            {
                return;
            }
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty &&
                SessionerHelper.ExamLevel.ToSafeString() != string.Empty &&
                SessionerHelper.SpecialityKindsNO.ToSafeString() != string.Empty)
            {
                Appointment_MakeAppointmentForm_Second_List form = new Appointment_MakeAppointmentForm_Second_List();
                form.Show();
            }
        }

        private void Lottery_MakeLotteryForm_Second_Click(object sender, EventArgs e)
        {
            if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty || SessionerHelper.ExamLevel.ToSafeString() == string.Empty || SessionerHelper.SpecialityKindsNO.ToSafeString() == string.Empty)
            {
                ChooseForm_SpecialityKinds option = new ChooseForm_SpecialityKinds();
                if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SetLabelText();
                }
            }
            if (SessionerHelper.SpecialityKindsNO.ToSafeString().Split(',').Length == 1)
            {
                return;
            }
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty &&
                SessionerHelper.ExamLevel.ToSafeString() != string.Empty &&
                SessionerHelper.SpecialityKindsNO.ToSafeString() != string.Empty)
            {
                Lottery_MakeLotteryForm_Second_List form = new Lottery_MakeLotteryForm_Second_List();
                form.Show();
            }
        }

        private void Appointment_MakeAppointmentForm_Third_Click(object sender, EventArgs e)
        {
            if (SessionerHelper.ExamPlaceID.ToSafeString() == string.Empty || SessionerHelper.ExamLevel.ToSafeString() == string.Empty || SessionerHelper.SpecialityKindsNO.ToSafeString() == string.Empty)
            {
                ChooseForm_SpecialityKinds option = new ChooseForm_SpecialityKinds();
                if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SetLabelText();
                }
                else
                {
                    return;
                }
            }
            if (SessionerHelper.ExamPlaceID.ToSafeString() != string.Empty &&
                SessionerHelper.ExamLevel.ToSafeString() != string.Empty &&
                SessionerHelper.SpecialityKindsNO.ToSafeString() != string.Empty)
            {
                Appointment_MakeAppointmentForm_Third_List form = new Appointment_MakeAppointmentForm_Third_List();
                form.Show();
            }
        }
        #endregion

        private void lbSelectData_Click(object sender, EventArgs e)
        {
            ChooseForm_SpecialityKinds option = new ChooseForm_SpecialityKinds();
            if (option.ShowDialog() == DialogResult.OK)
            {
                SetLabelText();
            }
        }

        #region 考试过程管理
        private void ExamProcess_SpeExamOnTimeSearchForm_Click(object sender, EventArgs e)
        {

        }

        private void ExamProcess_ExamRoomOnTimeSearchForm_Click(object sender, EventArgs e)
        {

        }

        private void ExamProcess_ExamVideoSearchForm_Click(object sender, EventArgs e)
        {

        }
        #endregion

        private void pictureEdit2_Click(object sender, EventArgs e)
        {
            ChooseForm option = new ChooseForm();
            if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SetLabelText();
            }
            else
            {
                return;
            }
            ScoreDisPlay form = new ScoreDisPlay();
            form.Show();
        }

        private void pictureEdit1_Click(object sender, EventArgs e)
        {
            Examinee_ExamGroup form = new Examinee_ExamGroup();
            form.Show();
        }
    }
}
